package com.ict.ms.trackPlayBack.facade.redis.redisService;

import com.ict.ms.trackPlayBack.facade.redis.dao.ITrackFuseDao;
import com.ict.ms.trackPlayBack.facade.redis.pojo.Fuse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by chenlong on 2016/11/14.
 */
@Service
public class TrackFuseService {
    public List<Fuse> getFuse_original(String mdv, int startTime, int endTime){
        try {
             ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/applicationContext3.xml");
            ITrackFuseDao iTrackFuseDao=(ITrackFuseDao)ac.getBean("iTrackFuseDao");
            List<Fuse> trackFuseList=iTrackFuseDao.getFuse_original(mdv, startTime, endTime);
            return trackFuseList;
        }catch (Exception e){
            System.out.println("Redis操作错误："+e);
            return null;
        }
    }

    public List<Fuse> getFuse_original_Track(String mdv, int limit){
        try {
            ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/applicationContext3.xml");
            ITrackFuseDao iTrackFuseDao=(ITrackFuseDao)ac.getBean("iTrackFuseDao");

            //正数变负数
            limit=0-limit;
            List<Fuse> trackFuseList=iTrackFuseDao.getFuse_original_Track(mdv, limit);
            return trackFuseList;
        }catch (Exception e){
            System.out.println("Redis操作错误："+e);
            return null;
        }
    }
}
